package com.foreknow.service.Impl;

import com.foreknow.dao.BusinessDao;
import com.foreknow.dao.impl.BusinessDaoImpl;
import com.foreknow.po.Business;
import com.foreknow.service.BusinessService;
import com.foreknow.util.DBUtil;

import java.sql.SQLException;
import java.util.List;

public class BusinessServiceImpl implements BusinessService {

    @Override
    public List<Business> listBusinessByOrderTypeId(int orderTypeId) {
        BusinessDao businessDao = new BusinessDaoImpl();
        List<Business> list = null;
        try {
            list = businessDao.listBusinessByOrderTypeId(orderTypeId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            DBUtil.close();
        }
        return list;
    }

    @Override
    public Business getBusinessById(int businessId) {
        BusinessDao businessDao = new BusinessDaoImpl();
        Business business = null;
        try {
            business = businessDao.getBusinessById(businessId);
        } catch (SQLException throwables) {
            throwables.printStackTrace();
        }finally {
            DBUtil.close();
        }
        return business;
    }
    public static void main(String[] args) {
        BusinessService businessService = new BusinessServiceImpl();
        List<Business> list = businessService.listBusinessByOrderTypeId(1);
        Business b =businessService.getBusinessById(10001);
        System.out.println(b.getBusinessName());
        System.out.println("-----");

    }
}
